#include <cstdlib>
#include <iostream>

using namespace std;

extern string Item[];
extern int Price[];
extern void PwrWrite();
extern int DeptPwr[10];
extern void UserWrite();
extern int DeptStat[7];

bool PutStat(int Buy);

int RandStore()
{
    return rand() % 3000 + 1;
}


void Store()
{
     int StoreNum;
     int Buy;
     StoreNum = RandStore();
     store:
     cout << "\nWelcome to Store #" << StoreNum << endl;
     cout << "What do you want to buy?" << endl;
     for(int x=0; x<11; x++)
     {
             cout << "(" << x+1 << ") ";
             cout << Item[x] << " $" << Price[x] << endl;
     }
     cout << "\n(ITEM #)>>>";
     cin >> Buy;
     if(!PutStat(Buy-1))
     {
     cout << "Purchase Failed! You need money." << endl;
     system("cls");
     goto store;
     }
     else
     cout << "Purchase Successful!" << endl;
}

bool PutStat(int Buy)
{
     if(Price[Buy] <= DeptStat[3])
     {
      if(Buy != 10)
      {
       DeptPwr[Buy] += 1;
       PwrWrite();
      
      }
     else
     {
      DeptStat[2] += 20;
      UserWrite();
     }
     return true;
    }
    else
    {
        return false;
    }
}
